﻿using ConsoleApplication.WebAPI;
using Kingdee.BOS.App.Data;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Util;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace NS
{
    [HotUpdate]
    [Description("新品规则表审核后新增物料")]
    public class CreateMaterialService : AbstractOperationServicePlugIn
    {
        public override void OnPreparePropertys(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.PreparePropertysEventArgs e)
        {
            e.FieldKeys.Add("FID");
            e.FieldKeys.Add("FName");
            e.FieldKeys.Add("F_WNEG_Text1");
            e.FieldKeys.Add("FMATERIALID");
            e.FieldKeys.Add("F_WNEG_Specification");
            e.FieldKeys.Add("F_WNEG_Text5");
            e.FieldKeys.Add("F_WNEG__QZPV_Remark");
            e.FieldKeys.Add("F_WNEG_Group");
            e.FieldKeys.Add("F_WNEG_Base2");
            e.FieldKeys.Add("F_WNEG_ErpClsID");
            e.FieldKeys.Add("F_WNEG_BaseUnitId");
            e.FieldKeys.Add("F_WNEG__WLLZ_Text");
            e.FieldKeys.Add("F_WNEG_LargeText");
            e.FieldKeys.Add("F_WNEG__QZPV_Price");
            e.FieldKeys.Add("F_WNEG__QZPV_Text1");
            e.FieldKeys.Add("F_WNEG__WLLZ_TaxRateId");
            e.FieldKeys.Add("F_WNEG__QZPV_Price1");
            e.FieldKeys.Add("F_WNEG_Assistant");
            e.FieldKeys.Add("F_WNEG_TaxRateId1");
            e.FieldKeys.Add("FSupplierId");
            e.FieldKeys.Add("F_WNEG_Decimal");
            e.FieldKeys.Add("F_WNEG_Decimal1");
            e.FieldKeys.Add("F_WNEG_Decimal2");
            e.FieldKeys.Add("F_WNEG_Decimal3");
            e.FieldKeys.Add("F_WNEG_LENGTH");
            e.FieldKeys.Add("F_WNEG_WIDTH");
            e.FieldKeys.Add("F_WNEG_HEIGHT");
            e.FieldKeys.Add("F_WNEG__WLLZ_Qty1");
            e.FieldKeys.Add("F_WNEG__WLLZ_Qty2");
            e.FieldKeys.Add("F_WNEG__WLLZ_Qty");
            e.FieldKeys.Add("F_WNEG__QZPV_LENGTH");
            e.FieldKeys.Add("F_WNEG__QZPV_WIDTH");
            e.FieldKeys.Add("F_WNEG__QZPV_HEIGHT");
            e.FieldKeys.Add("F_WNEG__QZPV_VOLUME");
            e.FieldKeys.Add("F_WNEG__QZPV_Qty");
            e.FieldKeys.Add("FDESCRIPTION");
            e.FieldKeys.Add("F_WNEG_Text14");
            //e.FieldKeys.Add("F_WNEG_Remark5");
            e.FieldKeys.Add("F_WNEG_Remark4");
            e.FieldKeys.Add("F_WNEG_MulAssistant");
            e.FieldKeys.Add("F_WNEG_MulBase");
            e.FieldKeys.Add("F_WNEG_PURCHASERID");
            e.FieldKeys.Add("FCreatorId");
            e.FieldKeys.Add("F_WNEG_Base3");
            e.FieldKeys.Add("F_WNEG_Remark1");
            e.FieldKeys.Add("F_WNEG_Date");
        }
        public override void AfterExecuteOperationTransaction(AfterExecuteOperationTransaction e)
        {
            base.AfterExecuteOperationTransaction(e);
        string F_WNEG_Specification = "", F_WNEG_Group = "", F_WNEG_ErpClsID = "", FName = "",
                    F_WNEG_BaseUnitId = "", F_WNEG__WLLZ_Text = "", F_WNEG_LargeText = "",
                    F_WNEG__QZPV_Price = "", F_WNEG__QZPV_Text1 = "", F_WNEG__WLLZ_TaxRateId = "", F_WNEG__QZPV_Price1 = "",
                    F_WNEG_Assistant = "", F_WNEG_TaxRateId1 = "", F_WNEG_Decimal = "", F_WNEG_Decimal1 = "", F_WNEG_Decimal2 = "", F_WNEG_Decimal3 = "",
                    F_WNEG_LENGTH = "", F_WNEG_WIDTH = "", F_WNEG_HEIGHT = "", F_WNEG__WLLZ_Qty1 = "", F_WNEG__WLLZ_Qty2 = "", F_WNEG__WLLZ_Qty = "",
                    F_WNEG__QZPV_LENGTH = "", F_WNEG__QZPV_WIDTH = "", F_WNEG__QZPV_HEIGHT = "", F_WNEG__QZPV_VOLUME = "", F_WNEG__QZPV_Qty = "", F_WNEG_Text1 = "", FMATERIALID = "",
                    MESSAGE = "", F_WNEG_Base2 = "", F_WNEG_Text5 = "", F_WNEG__QZPV_Remark = "", FSupplierId = "", ID = "", F_WNEG_Image1 = "", FDESCRIPTION="",
                    F_WNEG_Text14="", F_WNEG_Remark5="", F_WNEG_Remark4="", FdataValue="",SUMFdataValue="", FdataValue1="", SUMFdataValue1="", F_WNEG_PURCHASERID="", FCreatorld="", F_WNEG_Base3="",
                    F_WNEG_Remark1="", F_WNEG_Date="";
            foreach (DynamicObject item1 in e.DataEntitys)
            {
                if (item1["ID"] != null && Convert.ToString(item1["ID"]) != "")
                {
                    ID = Convert.ToString(item1["ID"]);
                }
                if (item1["Name"] != null && Convert.ToString(item1["Name"]) != "")
                {
                    FName = Convert.ToString(item1["Name"]);
                }
                if (item1["F_WNEG_Text1"] != null && Convert.ToString(item1["F_WNEG_Text1"]) != "")
                {
                    F_WNEG_Text1 = Convert.ToString(item1["F_WNEG_Text1"]);
                }
                if (item1["F_WNEG_Specification"] != null && Convert.ToString(item1["F_WNEG_Specification"]) != "")
                {
                    F_WNEG_Specification = Convert.ToString(item1["F_WNEG_Specification"]);
                }
                if (item1["F_WNEG_Text5"] != null && Convert.ToString(item1["F_WNEG_Text5"]) != "")
                {
                    F_WNEG_Text5 = Convert.ToString(item1["F_WNEG_Text5"]);
                }
                if (item1["F_WNEG__QZPV_Remark"] != null && Convert.ToString(item1["F_WNEG__QZPV_Remark"]) != "")
                {
                    F_WNEG__QZPV_Remark = Convert.ToString(item1["F_WNEG__QZPV_Remark"]);
                }
                if (item1["MaterialGroup"] != null && Convert.ToString(item1["MaterialGroup"]) != "")
                {
                    F_WNEG_Group = Convert.ToString((item1["MaterialGroup"] as DynamicObject)["Number"]);
                }
                if (item1["F_WNEG_Base2"] != null && Convert.ToString(item1["F_WNEG_Base2"]) != "")
                {
                    F_WNEG_Base2 = Convert.ToString((item1["F_WNEG_Base2"] as DynamicObject)["Number"]);
                }
                if (item1["F_WNEG_ErpClsID"] != null && Convert.ToString(item1["F_WNEG_ErpClsID"]) != "")
                {
                    F_WNEG_ErpClsID = Convert.ToString(item1["F_WNEG_ErpClsID"]);
                }
                if (item1["F_WNEG_BaseUnitId"] != null && Convert.ToString(item1["F_WNEG_BaseUnitId"]) != "")
                {
                    F_WNEG_BaseUnitId = Convert.ToString((item1["F_WNEG_BaseUnitId"] as DynamicObject)["Number"]);
                }
                if (item1["F_WNEG__WLLZ_Text"] != null && Convert.ToString(item1["F_WNEG__WLLZ_Text"]) != "")
                {
                    F_WNEG__WLLZ_Text = Convert.ToString(item1["F_WNEG__WLLZ_Text"]);
                }
                if (item1["F_WNEG_LargeText"] != null && Convert.ToString(item1["F_WNEG_LargeText"]) != "")
                {
                    F_WNEG_LargeText = Convert.ToString(item1["F_WNEG_LargeText"]);
                }
                if (item1["F_WNEG__QZPV_Price"] != null && Convert.ToString(item1["F_WNEG__QZPV_Price"]) != "")
                {
                    F_WNEG__QZPV_Price = Convert.ToString(item1["F_WNEG__QZPV_Price"]);
                }
                if (item1["F_WNEG__QZPV_Text1"] != null && Convert.ToString(item1["F_WNEG__QZPV_Text1"]) != "")
                {
                    F_WNEG__QZPV_Text1 = Convert.ToString(item1["F_WNEG__QZPV_Text1"]);
                }
                if (item1["F_WNEG__WLLZ_TaxRateId"] != null && Convert.ToString(item1["F_WNEG__WLLZ_TaxRateId"]) != "")
                {
                    F_WNEG__WLLZ_TaxRateId = Convert.ToString((item1["F_WNEG__WLLZ_TaxRateId"] as DynamicObject)["Number"]);
                }
                if (item1["F_WNEG__QZPV_Price1"] != null && Convert.ToString(item1["F_WNEG__QZPV_Price1"]) != "")
                {
                    F_WNEG__QZPV_Price1 = Convert.ToString(item1["F_WNEG__QZPV_Price1"]);
                }
                if (item1["F_WNEG_Assistant"] != null && Convert.ToString(item1["F_WNEG_Assistant"]) != "")
                {
                    F_WNEG_Assistant = Convert.ToString((item1["F_WNEG_Assistant"] as DynamicObject)["FNumber"]);
                }
                if (item1["F_WNEG_TaxRateId1"] != null && Convert.ToString(item1["F_WNEG_TaxRateId1"]) != "")
                {
                    F_WNEG_TaxRateId1 = Convert.ToString((item1["F_WNEG_TaxRateId1"] as DynamicObject)["Number"]);
                }
                if (item1["FSupplierId"] != null && Convert.ToString(item1["FSupplierId"]) != "")
                {
                    FSupplierId = Convert.ToString((item1["FSupplierId"] as DynamicObject)["Number"]);
                }
                if (item1["F_WNEG_Decimal"] != null && Convert.ToString(item1["F_WNEG_Decimal"]) != "")
                {
                    F_WNEG_Decimal = Convert.ToString(item1["F_WNEG_Decimal"]);
                }
                if (item1["F_WNEG_Decimal1"] != null && Convert.ToString(item1["F_WNEG_Decimal1"]) != "")
                {
                    F_WNEG_Decimal1 = Convert.ToString(item1["F_WNEG_Decimal1"]);
                }
                if (item1["F_WNEG_Decimal2"] != null && Convert.ToString(item1["F_WNEG_Decimal2"]) != "")
                {
                    F_WNEG_Decimal2 = Convert.ToString(item1["F_WNEG_Decimal2"]);
                }
                if (item1["F_WNEG_Decimal3"] != null && Convert.ToString(item1["F_WNEG_Decimal3"]) != "")
                {
                    F_WNEG_Decimal3 = Convert.ToString(item1["F_WNEG_Decimal3"]);
                }
                if (item1["F_WNEG_LENGTH"] != null && Convert.ToString(item1["F_WNEG_LENGTH"]) != "")
                {
                    F_WNEG_LENGTH = Convert.ToString(item1["F_WNEG_LENGTH"]);
                }
                if (item1["F_WNEG_WIDTH"] != null && Convert.ToString(item1["F_WNEG_WIDTH"]) != "")
                {
                    F_WNEG_WIDTH = Convert.ToString(item1["F_WNEG_WIDTH"]);
                }
                if (item1["F_WNEG_HEIGHT"] != null && Convert.ToString(item1["F_WNEG_HEIGHT"]) != "")
                {
                    F_WNEG_HEIGHT = Convert.ToString(item1["F_WNEG_HEIGHT"]);
                }
                if (item1["F_WNEG__WLLZ_Qty1"] != null && Convert.ToString(item1["F_WNEG__WLLZ_Qty1"]) != "")
                {
                    F_WNEG__WLLZ_Qty1 = Convert.ToString(item1["F_WNEG__WLLZ_Qty1"]);
                }
                if (item1["F_WNEG__WLLZ_Qty2"] != null && Convert.ToString(item1["F_WNEG__WLLZ_Qty2"]) != "")
                {
                    F_WNEG__WLLZ_Qty2 = Convert.ToString(item1["F_WNEG__WLLZ_Qty2"]);
                }
                if (item1["F_WNEG__WLLZ_Qty"] != null && Convert.ToString(item1["F_WNEG__WLLZ_Qty"]) != "")
                {
                    F_WNEG__WLLZ_Qty = Convert.ToString(item1["F_WNEG__WLLZ_Qty"]);
                }
                if (item1["F_WNEG__QZPV_LENGTH"] != null && Convert.ToString(item1["F_WNEG__QZPV_LENGTH"]) != "")
                {
                    F_WNEG__QZPV_LENGTH = Convert.ToString(item1["F_WNEG__QZPV_LENGTH"]);
                }
                if (item1["F_WNEG__QZPV_WIDTH"] != null && Convert.ToString(item1["F_WNEG__QZPV_WIDTH"]) != "")
                {
                    F_WNEG__QZPV_WIDTH = Convert.ToString(item1["F_WNEG__QZPV_WIDTH"]);
                }
                if (item1["F_WNEG__QZPV_HEIGHT"] != null && Convert.ToString(item1["F_WNEG__QZPV_HEIGHT"]) != "")
                {
                    F_WNEG__QZPV_HEIGHT = Convert.ToString(item1["F_WNEG__QZPV_HEIGHT"]);
                }
                if (item1["F_WNEG__QZPV_VOLUME"] != null && Convert.ToString(item1["F_WNEG__QZPV_VOLUME"]) != "")
                {
                    F_WNEG__QZPV_VOLUME = Convert.ToString(item1["F_WNEG__QZPV_VOLUME"]);
                }
                if (item1["F_WNEG__QZPV_Qty"] != null && Convert.ToString(item1["F_WNEG__QZPV_Qty"]) != "")
                {
                    F_WNEG__QZPV_Qty = Convert.ToString(item1["F_WNEG__QZPV_Qty"]);
                }
                if (item1["Description"] != null && Convert.ToString(item1["Description"]) != "")
                {
                    FDESCRIPTION = Convert.ToString(item1["Description"]);
                }
                if (item1["F_WNEG_Text14"] != null && Convert.ToString(item1["F_WNEG_Text14"]) != "")
                {
                    F_WNEG_Text14 = Convert.ToString(item1["F_WNEG_Text14"]);
                }
                //if (item1["F_WNEG_Remark5"] != null && Convert.ToString(item1["F_WNEG_Remark5"]) != "")
                //{
                //    F_WNEG_Remark5 = Convert.ToString(item1["F_WNEG_Remark5"]);
                //}
                if (item1["F_WNEG_Remark4"] != null && Convert.ToString(item1["F_WNEG_Remark4"]) != "")
                {
                    F_WNEG_Remark4 = Convert.ToString(item1["F_WNEG_Remark4"]);
                }
                if (item1["F_WNEG_MulAssistant"] != null && Convert.ToString(item1["F_WNEG_MulAssistant"]) != "")
                {
                    DynamicObjectCollection F_WNEG_MulAssistant = item1["F_WNEG_MulAssistant"] as DynamicObjectCollection;
                    if (F_WNEG_MulAssistant.Count > 0)
                    {
                        foreach(var item12 in F_WNEG_MulAssistant)
                        {
                            FdataValue=Convert.ToString((item12["F_WNEG_MulAssistant"] as DynamicObject)["FDataValue"]);
                            SUMFdataValue = SUMFdataValue + "," + FdataValue;
                        }
                        SUMFdataValue = SUMFdataValue.TrimEnd(',');
                        SUMFdataValue = SUMFdataValue.TrimStart(',');
                    }
                }
                if (item1["F_WNEG_MulBase"] != null && Convert.ToString(item1["F_WNEG_MulBase"]) != "")
                {
                    DynamicObjectCollection F_WNEG_MulBase = item1["F_WNEG_MulBase"] as DynamicObjectCollection;
                    if (F_WNEG_MulBase.Count > 0)
                    {
                        foreach (var item12 in F_WNEG_MulBase)
                        {
                            FdataValue1 = Convert.ToString((item12["F_WNEG_MulBase"] as DynamicObject)["Name"]);
                            SUMFdataValue1 = SUMFdataValue1 + "," + FdataValue1;
                        }
                        SUMFdataValue1 = SUMFdataValue1.TrimEnd(',');
                        SUMFdataValue1 = SUMFdataValue1.TrimStart(',');
                    }
                }
                if (item1["F_WNEG_PURCHASERID"] != null && Convert.ToString(item1["F_WNEG_PURCHASERID"]) != "")
                {
                    F_WNEG_PURCHASERID = Convert.ToString((item1["F_WNEG_PURCHASERID"] as DynamicObject)["Number"]);
                }
                if (item1["CreatorId"] != null && Convert.ToString(item1["CreatorId"]) != "")
                {
                    FCreatorld = Convert.ToString((item1["CreatorId"] as DynamicObject)["Name"]);
                }
                if (item1["F_WNEG_Base3"] != null && Convert.ToString(item1["F_WNEG_Base3"]) != "")
                {
                    F_WNEG_Base3 = Convert.ToString((item1["F_WNEG_Base3"] as DynamicObject)["Number"]);
                }
                if (item1["F_WNEG_Remark1"] != null && Convert.ToString(item1["F_WNEG_Remark1"]) != "")
                {
                    F_WNEG_Remark1 = Convert.ToString(item1["F_WNEG_Remark1"]);
                }
                if (item1["F_WNEG_Date"] != null && Convert.ToString(item1["F_WNEG_Date"]) != "")
                {
                    F_WNEG_Date = Convert.ToString(item1["F_WNEG_Date"]);
                }
                string SQL0 = "/*dialect*/" + string.Format(@"select FMATERIALID from T_BD_MATERIAL where fnumber='{0}'
                    ", F_WNEG_Text1);
                DynamicObjectCollection DynamData0 = DBUtils.ExecuteDynamicObject(this.Context, SQL0);
                if (DynamData0.Count > 0)
                {
                    FMATERIALID = Convert.ToString(DynamData0[0]["FMATERIALID"]);
                    MESSAGE = "修改成功！";
                }
                else
                {
                    FMATERIALID = "0";
                    MESSAGE = "新增成功！";
                }
                var result = InvokeHelper.Login();
                var iResult = JObject.Parse(result)["LoginResultType"].Value<int>();
                if (iResult == 1)
                {
                    JObject json = new JObject();
                    json.Add("IsDeleteEntry", "true");
                    json.Add("ValidateFlag", "true");
                    json.Add("IsAutoAdjustField", "true");
                    json.Add("IsAutoSubmitAndAudit", "true");
                    JObject item = new JObject();
                    item.Add("FMATERIALID", FMATERIALID);
                    JObject Obj = new JObject();
                    Obj.Add("FNumber", "100");
                    item.Add("FCreateOrgId", Obj);
                    Obj = new JObject();
                    Obj.Add("FNumber", "100");
                    item.Add("FUseOrgId", Obj);
                    item.Add("FNumber", F_WNEG_Text1);
                    item.Add("FName", FName);
                    item.Add("FSpecification", F_WNEG_Specification);
                    //item.Add("F_WNEG_Text5", F_WNEG_Text5);
                    item.Add("F_QZPV_Remark", F_WNEG__QZPV_Remark);
                    Obj = new JObject();
                    Obj.Add("FNumber", F_WNEG_Group);
                    item.Add("FMaterialGroup", Obj);
                    Obj = new JObject();
                    Obj.Add("FNumber", F_WNEG_Base2);
                    item.Add("F_WNEG_Base", Obj);
                    item.Add("F_WLLZ_Text", F_WNEG__WLLZ_Text);
                    item.Add("F_WNEG_LargeText", F_WNEG_LargeText);
                    item.Add("F_QZPV_Price", F_WNEG__QZPV_Price);
                    item.Add("F_QZPV_Text1", F_WNEG__QZPV_Text1);
                    Obj = new JObject();
                    Obj.Add("FNumber", F_WNEG__WLLZ_TaxRateId);
                    item.Add("F_WLLZ_TaxRateId", Obj);
                    item.Add("F_QZPV_Price1", F_WNEG__QZPV_Price1);
                    Obj = new JObject();
                    Obj.Add("FNumber", F_WNEG_Assistant);
                    item.Add("F_WNEG_Assistant", Obj);
                    Obj = new JObject();
                    Obj.Add("FNumber", F_WNEG_TaxRateId1);
                    item.Add("FTaxRateId1", Obj);
                    item.Add("F_WNEG_Decimal", F_WNEG_Decimal);
                    item.Add("F_WNEG_Decimal1", F_WNEG_Decimal1);
                    item.Add("F_WNEG_Decimal2", F_WNEG_Decimal2);
                    item.Add("F_WNEG_Decimal3", F_WNEG_Decimal3);

                    item.Add("F_WLLZ_Qty2", F_WNEG__WLLZ_Qty2);
                    item.Add("F_WLLZ_Qty", F_WNEG__WLLZ_Qty);

                    item.Add("F_QZPV_Qty", F_WNEG__QZPV_Qty);
                    item.Add("F_WNEG_MulLangText", FDESCRIPTION);
                    //item.Add("F_WNEG_Text14", F_WNEG_Text14);
                    //item.Add("F_WNEG_Remark5", F_WNEG_Remark5);
                    item.Add("F_WNEG_Remark4", F_WNEG_Remark4);
                    item.Add("F_WNEG_Text14", SUMFdataValue);
                    item.Add("F_WNEG_Text5", SUMFdataValue1);
                    item.Add("F_WNEG_Text15", FCreatorld);
                    item.Add("F_WLLZ_Remark", F_WNEG_Remark1);
                    item.Add("F_WNEG_Date", F_WNEG_Date);
                    Obj = new JObject();
                    Obj.Add("FNumber", F_WNEG_Base3);
                    item.Add("F_WNEG_Base2", Obj);

                    JObject SubHeadEntity = new JObject();
                    SubHeadEntity.Add("FErpClsID", F_WNEG_ErpClsID);
                    SubHeadEntity.Add("FLENGTH", F_WNEG_LENGTH);
                    SubHeadEntity.Add("FWIDTH", F_WNEG_WIDTH);
                    SubHeadEntity.Add("FHEIGHT", F_WNEG_HEIGHT);
                    SubHeadEntity.Add("F_WLLZ_Qty1", F_WNEG__WLLZ_Qty1);
                    SubHeadEntity.Add("F_QZPV_LENGTH", F_WNEG__QZPV_LENGTH);
                    SubHeadEntity.Add("F_QZPV_WIDTH", F_WNEG__QZPV_WIDTH);
                    SubHeadEntity.Add("F_QZPV_HEIGHT", F_WNEG__QZPV_HEIGHT);
                    SubHeadEntity.Add("F_QZPV_VOLUME", F_WNEG__QZPV_VOLUME);
                    Obj = new JObject();
                    Obj.Add("FNumber", F_WNEG_BaseUnitId);
                    SubHeadEntity.Add("FBaseUnitId", Obj);

                    item.Add("SubHeadEntity", SubHeadEntity);
                    JObject SubHeadEntity3 = new JObject();
                    Obj = new JObject();
                    Obj.Add("FNumber", FSupplierId);
                    SubHeadEntity3.Add("FDefaultVendor", Obj);
                    Obj = new JObject();
                    Obj.Add("FNumber", F_WNEG_PURCHASERID);
                    SubHeadEntity3.Add("FPurchaserId", Obj);
                    item.Add("SubHeadEntity3", SubHeadEntity3);
                    json.Add("Model", item);
                    result = InvokeHelper.Save("BD_MATERIAL", json.ToString());
                    var result0 = JObject.Parse(result);
                    var IsSuccess = result0["Result"]["ResponseStatus"]["IsSuccess"];
                    var SuccessEntitysId = result0["Result"]["ResponseStatus"]["SuccessEntitys"][0]["Id"];
                    if (IsSuccess.ToString().Equals("True"))
                    {

                        string SQL2 = "/*dialect*/" + string.Format(@"UPDATE  t SET t.FIMAGE=t1.F_WNEG_Image1,T.FIMGSTORAGETYPE='A' from T_BD_MATERIAL t
                        left join WNEG_t_Cust100018 t1 on t.fnumber=t1.F_WNEG_Text1
                        WHERE t.FMATERIALID='{0}'
                        ", SuccessEntitysId);
                        DBUtils.ExecuteDynamicObject(this.Context, SQL2);
                        //this.View.ShowMessage(MESSAGE);
                    }
                    else
                    {
                        var Errors = result0["Result"]["ResponseStatus"]["Errors"];
                        throw new Exception(Errors.ToString());
                        //this.View.ShowErrMessage("新增或修改失败！'" + Errors + "'");
                    }
                }
            }
        }
    }
}
